﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharedGenomics.Workbench.Core
{
    public class WebServiceProxyFactory
    {
        public WebServiceProxyFactory(IWebServiceEndpointRegistry endpointReg)
        {
            this.EndpointRegistry = endpointReg;
        }

        public virtual T CreateProxy<T>() where T : System.Web.Services.Protocols.SoapHttpClientProtocol, new()
        {
            T proxy = new T();
            string serviceName = typeof(T).Name;
            proxy.Url = this.EndpointRegistry.GetEndpointForService(serviceName);
            return proxy;
        }

        private IWebServiceEndpointRegistry EndpointRegistry { get; set; }
    }
}
